import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
import { AvatarInfo } from "../../../resource/info/AvatarInfo";
import { Cache } from "../../../cache/Cache";
import { AvatarType } from "../../../resource/info/AvatarType";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { CareerConfig } from "../../../resource/CareerConfig";
import { ESex } from "../../../../../Message/Public/ESex";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { PlayerOpRegister } from "../../common/menu/PlayerOpRegister";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { _playerId } from "../../../../../this/_playerId";
type int = number;
//class ApplyMemberRender
    
    export  class ApplyMemberRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            addEventListener(flash.events.MouseEvent.ROLL_OVER, this.onMouseOver);
            addEventListener(flash.events.MouseEvent.ROLL_OUT, this.onMouseOut);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var arg0: Object;
            var imgName: string;

            var loc1;
            arg0 = arg1;
            super.data = arg0;
            this._guildApply = arg0 as SPublicMiniPlayer;
            imgName = AvatarInfo.getPlayerAvatarName(Cache.instance.role.entityInfo.camp, this._guildApply.sex, AvatarType.FRIEND, this._guildApply.avatarId);
            with ({}) 
            {
            };
            imgName.load(
#error('pushwith') {}
            , 
#error('pushwith') {}
            .onAvatarLoaded = (arg1: ImageInfo): void
            {
                avatarBitmap.bitmapData = arg1.bitmapData;
                avatarBitmap.width = 20;
                avatarBitmap.height = 20;
                return;
            })
            if (this._guildApply.online != 1) 
            {
                this.avatarBitmap.filters = [FilterConst.colorFilter];
            }
            else 
            {
                this.avatarBitmap.filters = [];
            }
            this.nameTxt.text = this._guildApply.name;
            this.careerTxt.text = CareerConfig.instance.getInfoByCode(this._guildApply.career).name;
            this.levelTxt.text = this._guildApply.level.toString();
            if (this._guildApply.sex != ESex._ESexMan) 
            {
                this.sexBitmap.bitmapData = GlobalClass.getBitmapData(ImagesConst.Chat_Woman);
            }
            else 
            {
                this.sexBitmap.bitmapData = GlobalClass.getBitmapData(ImagesConst.Chat_Man);
            }
            this._playerId = this._guildApply.entityId.id;
            this.agreeBtn.drawNow();
            this.refuseBtn.drawNow();
            if (this._playerMiniInfo == null) 
            {
                this._playerMiniInfo = new PlayerMiniInfo();
            }
            this._playerMiniInfo.miniPlayer = this._guildApply;
            PlayerOpRegister.Register(this._operSprite, this._playerMiniInfo);
            return;
        }

        /* internal  */init(): void
        {
            var loc1=0;
            loc1 = 11661567;
            if (!this._operSprite) 
            {
                this._operSprite = new Object /* flash.display.Sprite */();
                this._operSprite.graphics.beginFill(16777215, 0);
                this._operSprite.graphics.drawRect(0, 0, 570, 25);
                this._operSprite.graphics.endFill();
                this._operSprite.buttonMode = true;
                this._operSprite.useHandCursor = true;
                this._operSprite.cacheAsBitmap = true;
            }
            addChild(this._operSprite);
            this.avatarBitmap = new Object /* flash.display.Bitmap */();
            this.avatarBitmap.x = 13;
            this.avatarBitmap.y = 0;
            addChild(this.avatarBitmap);
            this.nameTxt = new Object /* flash.text.TextField */();
            this.nameTxt.mouseEnabled = false;
            this.nameTxt.x = 40;
            this.nameTxt.y = 0;
            this.nameTxt.height = 30;
            this.nameTxt.selectable = false;
            this.nameTxt.textColor = loc1;
            this.nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.nameTxt);
            this.levelTxt = new Object /* flash.text.TextField */();
            this.levelTxt.mouseEnabled = false;
            this.levelTxt.x = 155;
            this.levelTxt.y = 0;
            this.levelTxt.height = 30;
            this.levelTxt.width = 35;
            this.levelTxt.selectable = false;
            this.levelTxt.textColor = loc1;
            this.levelTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.levelTxt);
            this.sexBitmap = new Object /* flash.display.Bitmap */();
            this.sexBitmap.x = 240;
            this.sexBitmap.y = 2;
            addChild(this.sexBitmap);
            this.careerTxt = new Object /* flash.text.TextField */();
            this.careerTxt.mouseEnabled = false;
            this.careerTxt.x = 330;
            this.careerTxt.y = 0;
            this.careerTxt.height = 30;
            this.careerTxt.selectable = false;
            this.careerTxt.textColor = loc1;
            this.careerTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.careerTxt);
            this.agreeBtn = new GButton();
            this.agreeBtn.label = Language.getString(57136);
            this.agreeBtn.styleName = "Button";
            this.agreeBtn.setSize(50, 27);
            this.agreeBtn.move(425, 0);
            this.agreeBtn.drawNow();
            this.agreeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onAgreeBtnClickHandler);
            addChild(this.agreeBtn);
            this.refuseBtn = new GButton();
            this.refuseBtn.label = Language.getString(57137);
            this.refuseBtn.styleName = "Button";
            this.refuseBtn.setSize(50, 27);
            this.refuseBtn.move(485, 0);
            this.refuseBtn.drawNow();
            this.refuseBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onRefuseBtnClickHandler);
            addChild(this.refuseBtn);
            this._overSkin = GlobalClass.getScaleBitmap(ImagesConst.Friend_over);
            this._overSkin.width = 510;
            this._overSkin.height = 25;
            this._overSkin.x = 35;
            ObjCreate.createBg(10, 25, 570, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */onMouseOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            addChildAt(this._overSkin, 0);
            return;
        }

        /* internal  */onMouseOut(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!_selected) 
            {
                if (this._overSkin.parent) 
                {
                    removeChild(this._overSkin);
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                addChildAt(this._overSkin, 0);
            }
            else if (this._overSkin.parent) 
            {
                removeChild(this._overSkin);
            }
            return;
        }

        /* internal  */onAgreeBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildDealApply, {"toPlayerId": _playerId, "oper": true}));
            return;
        }

        /* internal  */onRefuseBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildDealApply, {"toPlayerId": _playerId, "oper": false}));
            return;
        }

        /* internal */ /* var */avatarBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */sexBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */careerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */agreeBtn: GButton;

        /* internal */ /* var */refuseBtn: GButton;

        /* internal */ /* var */_overSkin: ScaleBitmap;

        /* internal */ /* var */_operSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_guildApply: SPublicMiniPlayer;

        /* internal */ /* var */_playerId: int;

        /* internal */ /* var */_playerMiniInfo: PlayerMiniInfo;
    }
